package getools4me;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;



public class GeTools4meServlet extends MyHttpServlet {
	
	
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4943529788279143500L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		baos.reset();
		resp.setContentType("text/html");
		
		
		
		UserService us = UserServiceFactory.getUserService();
		User user = us.getCurrentUser();
		if(user!=null){
			System.out.println("Welcome, Mr. "+user.getNickname());
			
			// list all files
//			System.out.println(this.getClass().getResource("WEB-INF/web.xml").toString());
			
		}else{
			resp.sendRedirect(us.createLoginURL(req.getRequestURI()));
		}

		
		
		resp.getWriter().println(baos.toString());
	}
}
